// pages/nakedEye/nakedEye.js
var request = require("../../utils/request.js")
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    testList: [],
    info: "",
    info1: "",
    s: "0",
    m:"0"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.toastDialog = this.selectComponent("#toastDialog");//此处id和页面的 wxml中的id一致
    this.queryInfoList()

    wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline']})
  },
/**
 * 用户点击右上角分享
 */
onShareAppMessage (res) {
  return {
    title: '迪佳极视',
    path: 'pages/index/index',
    // imageUrl:'这个是显示的图片，不写就默认当前页面的截图',
    success: function (shareTickets) {
      console.info(shareTickets + '成功');
      // 转发成功
    },
    fail: function (res) {
      console.log(res + '失败');
      // 转发失败
    },
    complete:function(res){
      // 不管成功失败都会执行
    }
  }
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //查看详情
  showDetails: function (e) {
    console.log(e);
    wx.navigateTo({
      url: '../sjDetailes/sjDetailes?tid=' + e.currentTarget.dataset.id
    })
  },
  //切换他人
  gotoChangePersion: function (e) {
    console.log(e);
    wx.navigateTo({
      url: '../changePersionList/changePersionList?type=3'+'&uid='+this.data.userInfo.id
    })
  },
  //色觉列表
  queryInfoList: function () {
    var that = this;
    that.toastDialog.showDialog({ code: 'loading', message: '加载中', timeout: false }); //loading 加载框
    let data = { type: 3 }
    if(wx.getStorageSync("uid")!=undefined && wx.getStorageSync("uid")!=''){
      data.uid=wx.getStorageSync("uid")
    }
    request.postData('xcx/testList', data, function (res) {
      that.toastDialog.hideDialog(); //关闭loading提示框
      if (res.code == 0) {
        that.setData({
          userInfo: res.userInfo
        })
        if (res.testList.length != 0) {
          that.setData({
            testList: res.testList,
            s:'0',
            m:'0'
          })
        } else {
          that.setData({
            s: "1",
            m:'1',
            info: "暂无数据~"
          })
        }

      } else {
        that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
      }
    }, function (res) {
      that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
    });
  },
})